<template>
	<view>
		<u-button type="primary" text="testupdate" @click="testupdate"></u-button><br />
		{{updateRes}}
	</view>
</template>

<script>
	import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
	import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
	export default {
		data() {
			return {
				updateRes: '',
			}
		},
		onLoad() {
			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
				console.log("appid", plus.runtime.appid);
				console.log("appVersion", plus.runtime.version);
				console.log("widgetInfo", widgetInfo);
			})
			// #endif
		},
		methods: {
			async testupdate() {
				let res = await callCheckVersion()
				this.updateRes = res
				console.log(res);
				if (res.result.code > 0) {
					let r = await checkUpdate()
					console.log(r);
				} else {
					uni.showToast({
						title: res.result.message,
						icon: 'none'
					});
				}
			},
			getWgtInfo() {
				return new Promise((resolve, reject) => {
					plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
						resolve(wgtinfo)
					}, (e) => {
						reject(e)
					})
				})
			},
		}
	}
</script>

<style>

</style>
